package com.qi.sat;

import cn.dev33.satoken.stp.StpInterface;
import com.qi.pojo.entity.Role;
import com.qi.pojo.vo.UserDetails;
import com.qi.services.IUserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class StpInterfaceImpl implements StpInterface {

    @Resource
    private IUserService userService;

    /**
     * 获取当前登录用户的角色信息
     */
    @Override
    public List<String> getRoleList(Object o, String s) {
        UserDetails userDetails = userService.getCurUser();
        Role role = userDetails.getRole();
        List<String> roleList = new ArrayList<>();
        roleList.add(role.getRoleKey());
        return roleList;
    }

    @Override
    public List<String> getPermissionList(Object o, String s) {
        return null;
    }
}
